//
//  GZSelectAlbumVC.m
//  YTWaterFlowLayoutDemo
//
//  Created by soco on 2021/4/29.
//  Copyright © 2021 guojunwei. All rights reserved.
//

#import "GZSelectAlbumVC.h"
#import "GZSelectAlbumView.h"
#import "AliyunAlbumViewController.h"

@interface GZSelectAlbumVC ()

@property (nonatomic, strong) GZSelectAlbumView *mainView;

@end

@implementation GZSelectAlbumVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.mainView];
}

- (GZSelectAlbumView *)mainView{
    if (!_mainView) {
        __weak typeof(self) weakSelf = self;
        _mainView = [GZSelectAlbumView createGZSelectAlbumView];
        _mainView.popBlock = ^{
            __strong typeof(self) strongSelf = weakSelf;
            [strongSelf.navigationController popViewControllerAnimated:YES];
        };
        
        //相册列表
        _mainView.takingPhotoBlock = ^(UIButton * _Nonnull sender) {
            __strong typeof(self) strongSelf = weakSelf;
            
            AliyunAlbumViewController *vc = [[AliyunAlbumViewController alloc] init];
            vc.albumTitle = sender.titleLabel.text;
            vc.selectBlock = ^(AliyunAlbumModel *albumModel) {
                //把页面的标题换成切换后的相册名称
                [sender setTitle:albumModel.albumName forState:UIControlStateNormal];
                //发送通知，将albumModel带过去
                [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadAlbumAndVideo" object:albumModel];
            };
            [strongSelf.navigationController pushViewController:vc animated:YES];
        };
        
    }
    return _mainView;
}

@end
